# -*- coding: utf-8 -*-
import time
from selenium import webdriver
import unittest
import xlrd
from venv1.Page.loginPage import loginPage
from venv1.publicModule.login import login
from venv1.Page.inqueryPage import inqueryPage
from venv1.publicModule.inquery import inquery
from venv1.Page.policyIfmComPage import policyIfmComPage
from venv1.publicModule.policyIfmCom import policyIfmCom
from venv1.publicModule.UWfllowup import UWfllowup
class Insured_Case(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.maximize_window()
        self.driver.get("http://10.22.26.74:8080/dist/index.html#/")
        time.sleep(2)
        self.loginPage = loginPage(self.driver)
        self.login = login(self.driver)
        self.inqueryPage=inqueryPage(self.driver)
        self.inquery=inquery(self.driver)
        self.policyIfmComPage = policyIfmComPage(self.driver)
        self.policyIfmCom = policyIfmCom(self.driver)
        self.UWfllowup = UWfllowup(self.driver)
    def test01(self):
        filename= r'C:\Users\tanjm.ext\PycharmProjects\OWB\TestData\Data.xls'
        excel_open=xlrd.open_workbook(filename)
        table=excel_open.sheet_by_name('Sheet1')
        rows=table.nrows
        for i in range(2,rows):
            row_content=table.row_values(i)
            username=row_content[0]
            password=row_content[1]
            login.login(self,username,password)
    def test02(self):
        filename = r'C:\Users\tanjm.ext\PycharmProjects\OWB\TestData\Data.xls'
        excel_open = xlrd.open_workbook(filename)
        table = excel_open.sheet_by_name('Sheet1')
        rows = table.nrows
        for i in range(2, rows):
            row_content = table.row_values(i)
            PolicyNo = row_content[3]
            # 分配任务
            inquery.Assign_To(self,PolicyNo)
            # 信息确认
            policyIfmCom.PolicyIfm_comfire(self, PolicyNo)
            # 核保待处理（承保）
            UWfllowup.UW_fllowup(self, PolicyNo)
            # 核保待处理
            inquery.UWdecision(self, PolicyNo)


if __name__ == '__main__':
    suite = unittest.TestLoader.loadTestsFromTestCase(Insured_Case)
    unittest.TextTestRunner().run(suite)

